<div class="card">
  <div class="card-body">
    <h1 class="card-title"><%= gettext "Input" %> </h1>
    <!-- Input -->
    <%= case @decoded_input_data do %>
    <% {:error, :contract_not_verified, candidates} -> %>
    <div class="alert alert-info">
      <%= gettext "To see accurate decoded input data, the contract must be verified." %>
      <%= case @transaction do %>
        <% %{to_address: %{hash: hash}} -> %>
          <% path = address_verify_contract_path(@conn, :new, hash) %>
          <%= gettext "Verify the contract " %><a href="<%= path %>"><%= gettext "here" %></a>
        <% _ -> %>
          <%= nil %>
      <% end %>
    </div>
    <%= unless Enum.empty?(candidates) do %>
      <h3><%= gettext "Potential matches from contract method database:" %></h3>
      <%= gettext "IMPORTANT: This information is a best guess based on similar functions from other verified contracts." %>
      <%= gettext "To have guaranteed accuracy, use the link above to verify the contract's source code." %>

      <%= for {:ok, method_id, text, mapping} <- candidates do %>
        <hr/>
        <h3><%= text %>: </h3>

        <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %>
      <% end %>
    <% end %>
    <% {:ok, method_id, text, mapping} -> %>
      <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %>
    <% {:error, :contract_verified, candidates} -> %>
      <h3><%= gettext "Potential matches from our contract method database:" %></h3>
      <%= for {:ok, method_id, text, mapping} <- candidates do %>
        <hr/>
        <h3><%= text %>: </h3>
        <%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping) %>
      <% end %>
    <% _ -> %>
        <div class="alert alert-danger">
          <%= gettext "Failed to decode input data." %>
        </div>
    <% end %>
  </div>
</div>
